package edu.msg.jthr.backend.bean;

import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import edu.msg.jthr.backend.exception.ServiceException;
import edu.msg.jthr.backend.model.RecommendedCandidate;
import edu.msg.jthr.backend.repository.exception.RepositoryException;
import edu.msg.jthr.backend.repository.service.RecommendedCandidateRepository;
import edu.msg.jthr.backend.service.RecommendedCandidateService;
@Stateless (name = "RecommendedCandidateServiceBean", mappedName = "ejb/RecommendedCandidateService")
public class RecommendedCandidateServiceBean implements
		RecommendedCandidateService {
	@EJB
	private RecommendedCandidateRepository recommendedCandidateRepository;
	private static Logger LOG = LoggerFactory
			.getLogger(CandidateServiceBean.class);
	@Override
	public List<RecommendedCandidate> getAll() throws ServiceException {
		try {
			return recommendedCandidateRepository.getAll();
		} catch (RepositoryException e) {
			LOG.error("Get all Recommended Candidate error!" + e);
			throw new ServiceException("Get all Recommended Candidate error!",
					e);
		}
	}

	@Override
	public RecommendedCandidate getById(Long id) throws ServiceException {
		try {
			return recommendedCandidateRepository.getById(id);
		} catch (RepositoryException e) {
			LOG.error("Get Recommended Candidate by id error!" + e);
			throw new ServiceException("Get Recommended Candidate by id error!",
					e);
		}
	}

	@Override
	public void create(RecommendedCandidate obj) throws ServiceException {
		try {
			recommendedCandidateRepository.create(obj);
		} catch (RepositoryException e) {
			LOG.error("Create Recommended Candidate error!" + e);
			throw new ServiceException("Create Recommended Candidate error!",
					e);
		}

	}

	@Override
	public void delete(RecommendedCandidate obj) throws ServiceException {
		try {
			recommendedCandidateRepository.delete(obj);
		} catch (RepositoryException e) {
			LOG.error("Delete Recommended Candidate error!" + e);
			throw new ServiceException("Delete Recommended Candidate error!",
					e);
		}

	}

	@Override
	public RecommendedCandidate update(RecommendedCandidate obj)
			throws ServiceException {
		try {
			return recommendedCandidateRepository.update(obj);
		} catch (RepositoryException e) {
			LOG.error("Update Recommended Candidate error!" + e);
			throw new ServiceException("Update Recommended Candidate error!",
					e);
		}

	}

}
